home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Software of the Month Club / Amiga General Interest Volume 220 (1995)(SOMC)(Disk 2 of y)[SMCxxxC30Ix].zip / Amiga General Interest Volume 220 (1995)(SOMC)(Disk 2 of y)[SMCxxxC30Ix].adf / Typeface / Source / node.c < prev    next >
C/C++ Source or Header  |  1995-08-20  |  731b  |  45 lines

  1. /*************************/
  2. /*             */
  3. /* Node and list handing */
  4. /*             */
  5. /*************************/
  6.  
  7. #include "Typeface.h"
  8.  
  9. struct List *GetNewList(struct List **list)
  10. {
  11.   if (*list = AllocVec(sizeof(struct List),MEMF_CLEAR))
  12.   {
  13.     NewList(*list);
  14.     return(*list);
  15.   }
  16.   else return(NULL);
  17. }
  18.  
  19. struct Node *CreateNode(ULONG size,struct List *list)
  20. {
  21. struct Node *node = NULL;
  22.  
  23.   if (node = AllocVec(size,MEMF_CLEAR)) AddTail(list,node);
  24.   return(node);
  25. }
  26.  
  27. void RemoveList(struct List **list,BOOL all,(*hook)())
  28. {
  29. struct Node *node;
  30.  
  31.   if (*list != NULL)
  32.   {
  33.     while (node = RemHead(*list))
  34.     {
  35.       if (hook) hook(node);
  36.       FreeVec(node);
  37.     }
  38.     if (all)
  39.     {
  40.       FreeVec(*list);
  41.       *list = NULL;
  42.     }
  43.   }
  44. }
  45.